<%--
  Created by IntelliJ IDEA.
  User: liuqiumiao5
  Date: 2023/9/23
  Time: 17:07
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>短信登录</title>
</head>
<body>
<form method="post"  action="${pageContext.request.contextPath}/PhoneCodeServlet">

    手机号：<input type="text" name="phone" id="phone"> <a onclick="sendCode()">发送短信验证码</a><br/>
    验证码：<input type="text" name="code"><br/>
    <input type="submit">

</form>
<script>
    function  sendCode() {
        var phoneStr=$("#phone").val();
        $.ajax({
           url:"${pageContext.request.contextPath}/SMSLoginServlet" ,
            data:{"phone":phoneStr},
            success:function (data) {
                if(data==0){
                    alert("发送成功！")
                }else{
                    alert("发送失败")
                }
            }
        });

    }

</script>
</body>
</html>
